package sjtu.ist.warehouse4ws.tool;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

public class XmlFileToString {

	public String readXmlFile(String path) throws IOException{
		StringBuffer xml = new StringBuffer();
		String xmlContent = null;
		String tempString=null;
		File file=new File(path);
		BufferedReader reader=null;
		try {
			InputStreamReader isr = new InputStreamReader(new FileInputStream(file),"utf-8");  //encoding is important
			reader=new BufferedReader(isr);
			
			while((tempString=reader.readLine())!=null){
				xml.append(tempString);
				
				xml.append("lineChange");
				

			}
			xmlContent=xml.toString();
			xmlContent=xmlContent.replaceAll("/", "slash");
			xmlContent=xmlContent.replaceAll("\"", "quotation");
			System.out.println(xmlContent);
			
			reader.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(reader!=null){
				reader.close();
			}
		}
		return xmlContent;
	}


}
